package com.bolehui.web;

import com.bolehui.base.result.Result;
import com.bolehui.domain.vo.JobVO;
import com.bolehui.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chendongjie     email:chendongjie@gz.iscas.ac.cn
 * @version 1.0
 * @ClassName JobManagementController
 * @Description 职位管理
 * @createTime 2024/12/11 14:33
 * Copyright (C) 2021-2022 CASEEDER, All Rights Reserved.
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 */
@RestController
@RequestMapping("/jobManagement.do")
public class JobController {

    @Autowired
    private JobService jobService;

    /**
     * 查看职位列表
     */
    @RequestMapping(params = "action=listJobs")
    public Result listJobs(Integer pageNum, Integer pageSize) throws Exception {
        return jobService.listJobs(pageNum, pageSize);
    }

    /**
     * 根据id查询职位信息
     *
     * @param id
     * @return
     */
    @RequestMapping(params = "action=getJobById")
    public Result getJobById(Long id) {
        return jobService.getJobById(id);
    }

    /**
     * 新增职位
     */
    @RequestMapping(params = "action=save")
    public Result save(@RequestBody JobVO job, Long userId) throws Exception {
        return jobService.save(job, userId);
    }

    @RequestMapping(params = "action=getJobWithPage")
    public Result getJobPage(Long userId, Integer pageNum, Integer pageSize) {
        return jobService.getJobWithPage(userId, pageNum, pageSize);
    }

    @RequestMapping(params = "action=postJob")
    public Result postJob(Long id) throws Exception {
        return jobService.postJob(id);
    }

    /**
     * 编辑职位信息
     */
    @RequestMapping(params = "action=editJob")
    public Result editJob(@RequestBody JobVO jobVO) throws Exception {
        return jobService.editJob(jobVO);
    }

    /**
     * 删除职位
     */
    @RequestMapping(params = "action=deleteJob")
    public Result deleteJob(Long id) throws Exception {
        return Result.success(jobService.removeById(id));
    }

    @RequestMapping(params = "action=getJobByUserId")
    public Result getJobByUserId(Long userId) {
        return jobService.getJobByUserId(userId);
    }

    @RequestMapping(params = "action=statisticsPostJob")
    public Result getJobStatsLastSixMonths() {
        return jobService.getJobStatsLastSixMonths();
    }

    @RequestMapping(params = "action=searchJobsWithQuery")
    public Result searchJobs(@RequestBody JobVO jobVO, Integer pageNum, Integer pageSize){
        return jobService.searchJobsWithQuery(jobVO, pageNum, pageSize);
    }
}
